Fix numerous instances of shadowing confusion. (#570)
authorGPSBabel <gpsbabel@users.noreply.github.com>
Wed, 27 May 2020 03:31:16 +0000 (22:31 -0500)
committerGitHub <noreply@github.com>
Wed, 27 May 2020 03:31:16 +0000 (22:31 -0500)
Fix numerous instances of shadowing confusion.

Inspired by a cppcon talk and our recent conversations about warnings, I
took a closer look at shadowing variables in our code and I wasn't proud
of my findings.

We had a lot of code that was writing to local variables or function
arguments when it thought it was operating on globals or (soon)
method-member variables. I made a rather half-hearted pass at changing
this by splitting up huge functions, renaming arguments, renaming globals
to reflect their future status as method variables (foo_), and generally
cleaning things up. The amound of effort I spent on each format was
approximately equal to its expected lifespan - I'm not spending an hour
on cleanups on formats I should instead be deleting.

In a future submit, I'll try to find some combination of -W flags on
our targets that allows us to not regress easily.

34 files changed:
alan.cc
bcr.cc
brauniger_iq.cc
compegps.cc
dg-100.cc
dmtlog.cc
duplicate.cc
exif.cc
garmin.cc
garmin_gpi.cc
garmin_txt.cc
gdb.cc
ggv_ovl.cc
globalsat_sport.cc
gui/gpsbabel [new file with mode: 0755]
humminbird.cc
igc.cc
ignrando.cc
itracku.cc
jeeps/gpsread.cc
lowranceusr.cc
main.cc
mmo.cc
nmea.cc
osm.cc
pocketfms_bc.cc
raymarine.cc
route.cc
skyforce.cc
stmwpp.cc
unicsv.cc
xmldoc/formats/options/energympro-timezone.xml [new file with mode: 0644]
xmldoc/formats/options/globalsat-timezone.xml [new file with mode: 0644]
xol.cc

diff --git a/alan.cc b/alan.cc
index 1b21c7c57ec985d2dbfae0c1e40080358220ddf7..5efe64d4956246a3ad2a0fc966e0bff2c2bf8ad2 100644 (file)
--- a/alan.cc
+++ b/alan.cc
@@ -211,7 +211,7 @@ static unsigned int byte_order()
   // see https://en.cppreference.com/w/cpp/language/reinterpret_cast#Notes
   uint32_t test = BYTEORDER_TEST;
   unsigned char ptr[4];
-  
+
   static_assert(sizeof ptr == sizeof test, "byte order test construction failure.");
   memcpy(&ptr[0], &test, sizeof test);
 
@@ -511,9 +511,9 @@ static Waypoint* get_wpt(struct wprdata* wprdata, unsigned n)
   xfree(s);
   for (j=WPT_COMMENT_LEN-1; j >= 0 && wpt->comment[j] == ' '; j--) {}
   if (j >= 0) {
-    char *s = xstrndup(wpt->comment, j+1);
-    WP->description = s;
-    xfree(s);
+    char *descr = xstrndup(wpt->comment, j+1);
+    WP->description = descr;
+    xfree(descr);
   } else {
     WP->description = "";
   }
@@ -562,9 +562,9 @@ static void wpr_read()
     xfree(s);
     for (j=RTE_COMMENT_LEN-1; j >= 0 && rte->comment[j] == ' '; j--) {}
     if (j >= 0) {
-      char *s = xstrndup(rte->comment,j+1);
-      RT->rte_desc = s;
-      xfree(s);
+      char *desc = xstrndup(rte->comment,j+1);
+      RT->rte_desc = desc;
+      xfree(desc);
     } else {
       RT->rte_desc = "";
     }
diff --git a/bcr.cc b/bcr.cc
index 67f58732c5d405d3bd91201df4ff90606b197a75..411577b75f2161745457c7c7c9e8171fdd46019d 100644 (file)
--- a/bcr.cc
+++ b/bcr.cc
@@ -244,19 +244,15 @@ bcr_mercator_to_wgs84(const int north, const int east, double* lat, double* lon)
 static void
 bcr_data_read()
 {
-  QString str;
-
   auto* route = new route_head;
+  route_add_head(route);
 
-  str = inifile_readstr(ini, "client", "routename");
-  if (!str.isNull()) {
-    route->rte_name = str;
+  QString routename = inifile_readstr(ini, "client", "routename");
+  if (!routename.isNull()) {
+    route->rte_name = routename;
   }
 
-  route_add_head(route);
-
   for (int index = 1; index > 0; index ++) {
-
     char station[32];
     QString str;
     int mlat, mlon;            /* mercator data */
@@ -323,17 +319,17 @@ bcr_wr_deinit()
   gbfclose(fout);
 }
 
-static void bcr_write_line(gbfile* fout, const QString& key, const int* index, const QString& value)
+static void bcr_write_line(gbfile* fileout, const QString& key,
+    const int* index, const QString& value)
 {
-  if (value.isEmpty()) {                       /* this is mostly used in the world of windows */
-    /* so we respectfully add a CR/LF on each line */
-    gbfprintf(fout, "%s\r\n", CSTR(key));
+  if (value.isEmpty()) { // Windows. Add CR/LF on output.
+    gbfprintf(fileout, "%s\r\n", CSTR(key));
   } else {
     char* tmp = (value != nullptr) ? xstrdup(value) : xstrdup("");
     if (index != nullptr) {
-      gbfprintf(fout, "%s%d=%s\r\n", CSTR(key), *index, tmp);
+      gbfprintf(fileout, "%s%d=%s\r\n", CSTR(key), *index, tmp);
     } else {
-      gbfprintf(fout, "%s=%s\r\n", CSTR(key), tmp);
+      gbfprintf(fileout, "%s=%s\r\n", CSTR(key), tmp);
     }
     xfree(tmp);
   }
index b1d36bc13a1f263a71a83cdbbca91f9e24c9c7c4..88188259e19a722ac4d2b863282e30ec637e22b7 100644 (file)
@@ -51,7 +51,7 @@ inline state_t& operator++(state_t& s) // prefix
 {
   return s = static_cast<state_t>(s + 1);
 }
-inline const state_t operator++(state_t& s, int) // postfix
+inline state_t operator++(state_t& s, int) // postfix
 {
   state_t ret(s);
   s = ++s;
index aa0414477498cf1572888cf185479eff9901d7d5..5be0d50bf228dd3cc98cd90e61c9cb5c6b24f38e 100644 (file)
@@ -387,7 +387,6 @@ compegps_data_read()
 {
   char* buff;
   int line = 0;
-  int input_datum;
   Waypoint* wpt = nullptr;
   route_head* route = nullptr;
   route_head* track = nullptr;
index 33760b1732b18f2f46890b20e336de897118e21c..a9f47e7daa5f2b3bd876f45f2a76ee50122a1188 100644 (file)
--- a/dg-100.cc
+++ b/dg-100.cc
@@ -657,20 +657,20 @@ Dg100Format::common_rd_init(const QString& fname)
 }
 
 void
-Dg100Format::dg100_rd_init(const QString& fname, bool isfile)
+Dg100Format::dg100_rd_init(const QString& fname, bool is_file)
 {
   static const model_t dg100_model = { "DG-100", 115200, true, true, dg100_commands, sizeof(dg100_commands) / sizeof(dg100_command) };
   model = &dg100_model;
-  this->isfile = isfile;
+  this->isfile = is_file;
   common_rd_init(fname);
 }
 
 void
-Dg100Format::dg200_rd_init(const QString& fname, bool isfile)
+Dg100Format::dg200_rd_init(const QString& fname, bool is_file)
 {
   static const model_t dg200_model = { "DG-200", 230400, false, false, dg200_commands, sizeof(dg200_commands) / sizeof(dg100_command) };
   model = &dg200_model;
-  this->isfile = isfile;
+  this->isfile = is_file;
   common_rd_init(fname);
 }
 
index 5b27d10db0b3b6eab79b3a5429239c994af48c07..07fe094ae347de5aa6efda8a4ef165f42613543b 100644 (file)
--- a/dmtlog.cc
+++ b/dmtlog.cc
@@ -399,11 +399,9 @@ read_datum(gbfile* f)
 static void
 read_CTrackFile(const int version)
 {
-  char buf[128];
-  int i;
-
   int16_t u1 = gbfgetint16(fin);
 
+  char buf[128];
   gbfread(buf, 1, 10, fin);
   if ((u1 != 0x0a) || (strncmp("CTrackFile", buf, 10) != 0)) {
     fatal(MYNAME ": Unknown or invalid track file.\n");
@@ -426,7 +424,7 @@ read_CTrackFile(const int version)
   track_add_head(track);
 
   /* S1 .. S9: comments, hints, jokes, aso */
-  for (i = 0; i < 9; i++) {
+  for (int i = 0; i < 9; i++) {
     char* s = read_str(fin);
     xfree(s);
   }
@@ -469,7 +467,7 @@ read_CTrackFile(const int version)
 
   if (version == 8) {
 
-    i = gbfgetint16(fin);
+    int i = gbfgetint16(fin);
     i = gbfgetc(fin);
     if (i == 0) {
       return;
index 78f2befdf396463cd6d4f95ad8ee187301d0f010..6a4e77acca5132f90b1e82ec05cccc81579d487b 100644 (file)
@@ -140,7 +140,6 @@ int DuplicateFilter::compare(const void* a, const void* b)
 
 void DuplicateFilter::process()
 {
-  Waypoint* waypointp;
   btree_node* newnode, * btmp, * sup_tree = nullptr;
   btree_node* oldnode = nullptr;
   unsigned long crc = 0;
@@ -166,7 +165,7 @@ void DuplicateFilter::process()
   qsort(htable, ct, sizeof(*htable), compare);
 
   for (i=0; i<ct; i++) {
-    waypointp = htable[i].wpt;
+    auto waypointp = htable[i].wpt;
 
     memset(&dupe, '\0', sizeof(dupe));
 
diff --git a/exif.cc b/exif.cc
index 69ed24bcc416a9c698a15e8c7ace2212ea4f060f..bde4c5c3c714660ba53083db83c6e3286efe92b1 100644 (file)
--- a/exif.cc
+++ b/exif.cc
@@ -43,6 +43,7 @@
 #include <QtCore/QDate>            // for QDate
 #include <QtCore/QDateTime>        // for QDateTime
 #include <QtCore/QFile>            // for QFile
+#include <QtCore/QFileInfo>        // for QFileInfo
 #include <QtCore/QList>            // for QList<>::iterator, QList
 #include <QtCore/QPair>            // for QPair
 #include <QtCore/QRegExp>          // for QRegExp
@@ -140,12 +141,12 @@ struct ExifTag {
 
   // grow data vector, initializing any new elements to type T with value 0.
   template <typename T>
-  void grow(const int size)
+  void grow(const int new_size)
   {
     int old_size = data.size();
-    if (size > old_size) {
-      data.resize(size);
-      for (int idx = old_size; idx < size; ++idx) {
+    if (new_size > old_size) {
+      data.resize(new_size);
+      for (int idx = old_size; idx < new_size; ++idx) {
         data[idx] = 0;
       }
     }
@@ -185,9 +186,9 @@ struct ExifApp {
   }
 };
 
-static gbfile* fin, *fout;
+static gbfile* fin_, *fout_;
 static QList<ExifApp>* exif_apps;
-static ExifApp* exif_app;
+static ExifApp* exif_app_;
 static const Waypoint* exif_wpt_ref;
 static QDateTime exif_time_ref;
 static char exif_success;
@@ -368,32 +369,32 @@ exif_ifd_size(ExifIfd* ifd)
 static ExifApp*
 exif_load_apps()
 {
-  ExifApp* exif_app = nullptr;
+  exif_app_ = nullptr;
 
-  while (! gbfeof(fin)) {
+  while (! gbfeof(fin_)) {
     exif_apps->append(ExifApp());
     ExifApp* app = &exif_apps->last();
     app->fcache = gbfopen(nullptr, "wb", MYNAME);
 
-    app->marker = gbfgetuint16(fin);
-    app->len = gbfgetuint16(fin);
+    app->marker = gbfgetuint16(fin_);
+    app->len = gbfgetuint16(fin_);
     if (global_opts.debug_level >= 3) {
-      printf(MYNAME ": api = %02X, len = %u (0x%04x), offs = 0x%08X\n", app->marker & 0xFF, app->len, app->len, gbftell(fin));
+      printf(MYNAME ": api = %02X, len = %u (0x%04x), offs = 0x%08X\n", app->marker & 0xFF, app->len, app->len, gbftell(fin_));
     }
-    if (exif_app || (app->marker == 0xFFDA)) { /* compressed data */
-      gbfcopyfrom(app->fcache, fin, 0x7FFFFFFF);
+    if (exif_app_ || (app->marker == 0xFFDA)) { /* compressed data */
+      gbfcopyfrom(app->fcache, fin_, 0x7FFFFFFF);
       if (global_opts.debug_level >= 3) {
         printf(MYNAME ": compressed data size = %u\n", gbftell(app->fcache));
       }
     } else {
-      gbfcopyfrom(app->fcache, fin, app->len - 2);
+      gbfcopyfrom(app->fcache, fin_, app->len - 2);
       if (app->marker == 0xFFE1) {
-        exif_app = app;
+        exif_app_ = app;
       }
     }
   }
 
-  return exif_app;
+  return exif_app_;
 }
 
 #ifndef NDEBUG
@@ -770,10 +771,10 @@ exif_get_exif_time(ExifApp* app)
     }
 
     if (offset_tag) {
-      char* str = exif_read_str(offset_tag);
+      char* time_tag = exif_read_str(offset_tag);
       // string should be +HH:MM or -HH:MM
       QRegExp re("([+-])(\\d{2})(?::)(\\d{2})");
-      if (re.exactMatch(str)) {
+      if (re.exactMatch(time_tag)) {
         // Correct the date time by supplying the offset from UTC.
         int offset_hours = re.cap(1).append(re.cap(2)).toInt();
         int offset_mins = re.cap(1).append(re.cap(3)).toInt();
@@ -887,7 +888,6 @@ exif_waypt_from_exif_app(ExifApp* app)
       fatal(MYNAME ": Unknown GPSMapDatum \"%s\"!\n", datum);
     }
     if (idatum != DATUM_WGS84) {
-      double alt;
       GPS_Math_WGS84_To_Known_Datum_M(wpt->latitude, wpt->longitude, 0.0,
                                       &wpt->latitude, &wpt->longitude, &alt, idatum);
     }
@@ -977,24 +977,9 @@ exif_waypt_from_exif_app(ExifApp* app)
   }
 
   if (opt_filename) {
-    char* c;
-    char* str = xstrdup(fin->name);
-
-    char* cx = str;
-    if ((c = strrchr(cx, ':'))) {
-      cx = c + 1;
-    }
-    if ((c = strrchr(cx, '\\'))) {
-      cx = c + 1;
-    }
-    if ((c = strrchr(cx, '/'))) {
-      cx = c + 1;
-    }
-    if (((c = strchr(cx, '.'))) && (c != cx)) {
-      *c = '\0';
-    }
-    wpt->shortname = cx;
-    xfree(str);
+    QFileInfo fi(fin_->name);
+    // No directory, no extension.
+    wpt->shortname = fi.baseName();
   }
 
   return wpt;
@@ -1069,13 +1054,13 @@ exif_put_value(const int ifd_nr, const uint16_t tag_id, const uint16_t type, con
   ExifTag* tag = nullptr;
   uint16_t size;
 
-  ExifIfd* ifd = exif_find_ifd(exif_app, ifd_nr);
+  ExifIfd* ifd = exif_find_ifd(exif_app_, ifd_nr);
   if (ifd == nullptr) {
-    exif_app->ifds.append(ExifIfd());
-    ifd = &exif_app->ifds.last();
+    exif_app_->ifds.append(ExifIfd());
+    ifd = &exif_app_->ifds.last();
     ifd->nr = ifd_nr;
   } else {
-    tag = exif_find_tag(exif_app, ifd_nr, tag_id);
+    tag = exif_find_tag(exif_app_, ifd_nr, tag_id);
   }
 
   uint16_t item_size = exif_type_size(type);
@@ -1368,14 +1353,14 @@ exif_write_ifd(ExifIfd* ifd, const char next, gbfile* fout)
 static void
 exif_write_apps()
 {
-  gbfputuint16(0xFFD8, fout);
+  gbfputuint16(0xFFD8, fout_);
 
   for (auto& app_instance : *exif_apps) {
     ExifApp* app = &app_instance;
 
-    gbfputuint16(app->marker, fout);
+    gbfputuint16(app->marker, fout_);
 
-    if (app == exif_app) {
+    if (app == exif_app_) {
       assert(app->marker == 0xFFE1);
       uint32_t len = 8;
 
@@ -1465,15 +1450,15 @@ exif_write_apps()
 
       len = gbftell(ftmp);
       gbfrewind(ftmp);
-      gbfputuint16(len + 8, fout);
-      gbfwrite("Exif\0\0", 6, 1, fout);
-      gbfcopyfrom(fout, ftmp, len);
+      gbfputuint16(len + 8, fout_);
+      gbfwrite("Exif\0\0", 6, 1, fout_);
+      gbfcopyfrom(fout_, ftmp, len);
 
       gbfclose(ftmp);
     } else {
-      gbfputuint16(app->len, fout);
+      gbfputuint16(app->len, fout_);
       gbfrewind(app->fcache);
-      gbfcopyfrom(fout, app->fcache, 0x7FFFFFFF);
+      gbfcopyfrom(fout_, app->fcache, 0x7FFFFFFF);
     }
   }
 }
@@ -1485,7 +1470,7 @@ exif_write_apps()
 static void
 exif_rd_init(const QString& fname)
 {
-  fin = gbfopen_be(fname, "rb", MYNAME);
+  fin_ = gbfopen_be(fname, "rb", MYNAME);
   exif_apps = new QList<ExifApp>;
 }
 
@@ -1493,20 +1478,20 @@ static void
 exif_rd_deinit()
 {
   exif_release_apps();
-  gbfclose(fin);
+  gbfclose(fin_);
 }
 
 static void
 exif_read()
 {
-  uint16_t soi = gbfgetuint16(fin);
+  uint16_t soi = gbfgetuint16(fin_);
   is_fatal(soi != 0xFFD8, MYNAME ": Unknown image file.");  /* only jpeg for now */
 
-  exif_app = exif_load_apps();
-  is_fatal(exif_app == nullptr, MYNAME ": No EXIF header in source file \"%s\".", fin->name);
+  exif_app_ = exif_load_apps();
+  is_fatal(exif_app_ == nullptr, MYNAME ": No EXIF header in source file \"%s\".", fin_->name);
 
-  exif_examine_app(exif_app);
-  Waypoint* wpt = exif_waypt_from_exif_app(exif_app);
+  exif_examine_app(exif_app_);
+  Waypoint* wpt = exif_waypt_from_exif_app(exif_app_);
   if (wpt) {
     waypt_add(wpt);
   }
@@ -1520,24 +1505,24 @@ exif_wr_init(const QString& fname)
 
   exif_apps = new QList<ExifApp>;
 
-  fin = gbfopen_be(fname, "rb", MYNAME);
-  is_fatal(fin->is_pipe, MYNAME ": Sorry, this format cannot be used with pipes!");
+  fin_ = gbfopen_be(fname, "rb", MYNAME);
+  is_fatal(fin_->is_pipe, MYNAME ": Sorry, this format cannot be used with pipes!");
 
-  uint16_t soi = gbfgetuint16(fin);
+  uint16_t soi = gbfgetuint16(fin_);
   is_fatal(soi != 0xFFD8, MYNAME ": Unknown image file.");
-  exif_app = exif_load_apps();
-  is_fatal(exif_app == nullptr, MYNAME ": No EXIF header found in source file \"%s\".", fin->name);
-  exif_examine_app(exif_app);
-  gbfclose(fin);
+  exif_app_ = exif_load_apps();
+  is_fatal(exif_app_ == nullptr, MYNAME ": No EXIF header found in source file \"%s\".", fin_->name);
+  exif_examine_app(exif_app_);
+  gbfclose(fin_);
 
-  exif_time_ref = exif_get_exif_time(exif_app);
+  exif_time_ref = exif_get_exif_time(exif_app_);
   if (!exif_time_ref.isValid()) {
     fatal(MYNAME ": No valid timestamp found in picture!\n");
   }
 
   QString filename(fname);
   filename += ".jpg";
-  fout = gbfopen_be(filename, "wb", MYNAME);
+  fout_ = gbfopen_be(filename, "wb", MYNAME);
 }
 
 static void
@@ -1545,8 +1530,8 @@ exif_wr_deinit()
 {
 
   exif_release_apps();
-  QString tmpname = QString(fout->name);
-  gbfclose(fout);
+  QString tmpname = QString(fout_->name);
+  gbfclose(fout_);
 
   if (exif_success) {
     if (*opt_overwrite == '1') {
@@ -1586,8 +1571,8 @@ exif_write()
     if (exif_wpt_ref == nullptr) {
       warning(MYNAME ": No point with a valid timestamp found.\n");
     } else if (labs(exif_time_ref.secsTo(exif_wpt_ref->creation_time)) > frame) {
-      QString str = exif_time_str(exif_time_ref);
-      warning(MYNAME ": No matching point found for image date %s!\n", qPrintable(str));
+      QString time_str = exif_time_str(exif_time_ref);
+      warning(MYNAME ": No matching point found for image date %s!\n", qPrintable(time_str));
       if (exif_wpt_ref != nullptr) {
         QString str = exif_time_str(exif_wpt_ref->creation_time);
         warning(MYNAME ": Best is from %s, %ld second(s) away.\n",
index 1803d5ce132dcc2f6aeeeb4c4b32c3b5d1f3e04d..a58a2bfa33a9622723f833820b54d88570efc80b 100644 (file)
--- a/garmin.cc
+++ b/garmin.cc
@@ -124,7 +124,7 @@ static int d103_icon_number_from_symbol(const QString& s);
 static void
 rw_init(const QString& fname)
 {
-  int receiver_must_upper = 1;
+  receiver_must_upper = 1;
   const char* receiver_charset = nullptr;
 
   if (!mkshort_handle) {
index 3aff3c85baffbee3b9167f5afb7eee396b40d5b0..a3be2cb2cc525c7e1c901f1d239f8b1d5de92e86 100644 (file)
@@ -414,15 +414,12 @@ static int read_tag(const char* caller, int tag, Waypoint* wpt);
 static void
 read_poi(const int sz, const int tag)
 {
-  int pos, len;
-  Waypoint* wpt;
-
 #ifdef GPI_DBG
   PP;
   dbginfo("> reading poi (size %d)\n", sz);
 #endif
   PP;
-  len = 0;
+  int len = 0;
   if (tag == 0x80002) {
     len = gbfgetint32(fin);    /* sub-header size */
   }
@@ -430,9 +427,9 @@ read_poi(const int sz, const int tag)
   dbginfo("poi sublen = %1$d (0x%1$x)\n", len);
 #endif
   (void) len;
-  pos = gbftell(fin);
+  int pos = gbftell(fin);
 
-  wpt = new Waypoint;
+  Waypoint* wpt = new Waypoint;
   wpt->icon_descr = DEFAULT_ICON;
 
   wpt->latitude = GPS_Math_Semi_To_Deg(gbfgetint32(fin));
@@ -443,8 +440,8 @@ read_poi(const int sz, const int tag)
   wpt->shortname = gpi_read_string("Shortname");
 
   while (gbftell(fin) < (gbsize_t)(pos + sz - 4)) {
-    int tag = gbfgetint32(fin);
-    if (! read_tag("read_poi", tag, wpt)) {
+    int skip_tag = gbfgetint32(fin);
+    if (! read_tag("read_poi", skip_tag, wpt)) {
       break;
     }
   }
index 87f59ed135ce4764dd0eb6824e58821138a32230..5293eee28d40eae495894d75e5829a8825f644ee 100644 (file)
@@ -91,7 +91,7 @@ inline header_type& operator++(header_type& s) // prefix
 {
   return s = static_cast<header_type>(s + 1);
 }
-inline const header_type operator++(header_type& s, int) // postfix
+inline header_type operator++(header_type& s, int) // postfix
 {
   header_type ret(s);
   s = ++s;
@@ -102,7 +102,7 @@ inline gt_display_modes_e& operator++(gt_display_modes_e& s) // prefix
 {
   return s = static_cast<gt_display_modes_e>(s + 1);
 }
-inline const gt_display_modes_e operator++(gt_display_modes_e& s, int) // postfix
+inline gt_display_modes_e operator++(gt_display_modes_e& s, int) // postfix
 {
   gt_display_modes_e ret(s);
   s = ++s;
@@ -817,7 +817,7 @@ garmin_txt_write()
   grid_str = grid_str.replace('*', "°");
   *fout << "Grid\t" << grid_str << "\r\n";
 
-  const char* datum_str = gt_get_mps_datum_name(datum_index);
+  datum_str = gt_get_mps_datum_name(datum_index);
   *fout << QString::asprintf("Datum\t%s\r\n\r\n", datum_str);
 
   waypoints = 0;
diff --git a/gdb.cc b/gdb.cc
index 681f89c796683495590ee3bc58424eb50f56f474..9334cb986861d26494bf4328d216dc5f6dfa2b83 100644 (file)
--- a/gdb.cc
+++ b/gdb.cc
@@ -206,9 +206,9 @@ static QString fread_cstr()
 }
 
 static char*
-gdb_fread_cstr(gbfile* fin)
+gdb_fread_cstr(gbfile* file_in)
 {
-  char* result = gbfgetcstr_old(fin);
+  char* result = gbfgetcstr_old(file_in);
 
   if (result && (*result == '\0')) {
     xfree(result);
@@ -221,7 +221,6 @@ gdb_fread_cstr(gbfile* fin)
 static QString
 gdb_fread_strlist()
 {
-//  char* res = NULL;
   QString res;
 
   int count = FREAD_i32;
@@ -235,7 +234,6 @@ gdb_fread_strlist()
   }
 
   QString qres = res;
-//  xfree(res);
   return qres;
 }
 
@@ -427,12 +425,9 @@ static Waypoint*
 read_waypoint(gt_waypt_classes_e* waypt_class_out)
 {
   char buf[128];               /* used for temporary stuff */
-  int display, icon;
   gt_waypt_classes_e wpt_class;
-  int i;
   Waypoint* res;
   garmin_fs_t* gmsd;
-  QString str;
 #ifdef GMSD_EXPERIMENTAL
   char subclass[22];
 #endif
@@ -495,13 +490,13 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out)
            qPrintable(res->shortname), wpt_class, res->proximity / 1000);
 #endif
   }
-  i = FREAD_i32;
+  int display = FREAD_i32;
 #if GDB_DEBUG
   DBG(GDB_DBG_WPTe, i)
   printf(MYNAME "-wpt \"%s\" (%d): display = %d\n",
-         qPrintable(res->shortname), wpt_class, i);
+         qPrintable(res->shortname), wpt_class, display);
 #endif
-  switch (i) {                 /* display value */
+  switch (display) {                   /* display value */
   case gt_gdb_display_mode_symbol:
     display = gt_display_mode_symbol;
     break;
@@ -515,7 +510,7 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out)
   garmin_fs_t::set_display(gmsd, display);
 
   FREAD_i32;                           /* color !not implemented! */
-  icon = FREAD_i32;
+  int icon = FREAD_i32;
   garmin_fs_t::set_icon(gmsd, icon);
   garmin_fs_t::set_city(gmsd, fread_cstr());
   garmin_fs_t::set_state(gmsd, fread_cstr());
@@ -591,14 +586,14 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out)
   printf(MYNAME "-wpt \"%s\" (%d): url = %s\n",
          qPrintable(res->shortname), wpt_class, qPrintable(res->urls.GetUrlLink().url_));
 #endif
-  i = FREAD_i16;
-  if (i != 0) {
-    garmin_fs_t::set_category(gmsd, i);
+  int category = FREAD_i16;
+  if (category != 0) {
+    garmin_fs_t::set_category(gmsd, category);
   }
 #if GDB_DEBUG
-  DBG(GDB_DBG_WPTe, i)
+  DBG(GDB_DBG_WPTe, category)
   printf(MYNAME "-wpt \"%s\" (%d): category = %d\n",
-         qPrintable(res->shortname), wpt_class, i);
+         qPrintable(res->shortname), wpt_class, category);
 #endif
 
   if (FREAD_C == 1) {
@@ -637,6 +632,7 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out)
   printf(MYNAME "-wpt \"%s\" (%d): icon = \"%s\" (MapSource symbol %d)\n",
          qPrintable(res->shortname), wpt_class, qPrintable(res->icon_descr), icon);
 #endif
+  QString str;
   if (!(str = garmin_fs_t::get_cc(gmsd, nullptr)).isEmpty()) {
     if (! (garmin_fs_t::has_country(gmsd))) {
       garmin_fs_t::set_country(gmsd, gt_get_icao_country(str));
@@ -658,15 +654,14 @@ read_waypoint(gt_waypt_classes_e* waypt_class_out)
 static route_head*
 read_route()
 {
-  char buf[128];
-  bounds bounds;
-
   rte_ct++;
   int warnings = 0;
 
   auto* rte = new route_head;
   rte->rte_name = fread_cstr();
-  FREAD(buf, 1);                       /* display/autoname - 1 byte */
+
+  char tbuf[128];
+  FREAD(tbuf, 1);                      /* display/autoname - 1 byte */
 
   if (FREAD_C == 0) {          /* max. data flag */
     /* maxlat = */ (void) FREAD_i32;
@@ -720,8 +715,8 @@ read_route()
       }
       warning(MYNAME "-rte_pt \"%s\" (class %d): possible error in route.\n", qPrintable(wpt->shortname), wpt_class);
       warning(MYNAME "-rte_pt (dump):");
-      for (int i = 0; i < 18; i++) {
-        warning(" %02x", (unsigned char)buf[i]);
+      for (int idx = 0; idx < 18; idx++) {
+        warning(" %02x", (unsigned char)buf[idx]);
       }
       warning("\n");
     }
@@ -771,6 +766,7 @@ read_route()
 #endif
     }
 
+    bounds bounds;
     waypt_init_bounds(&bounds);
 
     if (FREAD_C == 0) {                /* interlink bounds */
@@ -843,10 +839,9 @@ read_route()
 
     int color_idx = FREAD_i32;
     rte->line_color.bbggrr = gt_color_value(color_idx);
-
     int autoroute = FREAD_C;
     if (autoroute == 1) {
-      FREAD(buf, 6); /* unknown bytes */
+      FREAD(tbuf, 6); /* unknown bytes */
       int route_style = FREAD_C;
       int calc_type = FREAD_i32;
       int vehicle_type = FREAD_C;
@@ -857,7 +852,7 @@ read_route()
       driving_speed[2] = FREAD_DBL;
       driving_speed[3] = FREAD_DBL;
       driving_speed[4] = FREAD_DBL;
-      FREAD(buf, 8); /* unknown bytes */
+      FREAD(tbuf, 8); /* unknown bytes */
 #if GDB_DEBUG
       DBG(GDB_DBG_RTE, 1)
       printf(MYNAME "-rte_pt: autoroute info: route style %d, calculation type %d, vehicle type %d, road selection %d\n"
index c14671e8100ab503eca41cd1a519cc62b124b9dd..98e10ceeb3296de334570ff1541995c784ce438e 100644 (file)
@@ -356,14 +356,15 @@ write_bounds()
 }
 
 static void
-draw_symbol_basics(const OVL_SYMBOL_TYP typ, const int art, const OVL_COLOR_TYP color, const Waypoint* wpt)
+draw_symbol_basics(const OVL_SYMBOL_TYP typ, const int art, 
+                   const OVL_COLOR_TYP point_color, const Waypoint* wpt)
 {
   symbol_ct++;
 
   gbfprintf(fout, "[Symbol %d]\n", symbol_ct);
   gbfprintf(fout, "Typ=%d\n", typ);
   gbfprintf(fout, "Group=%d\n", group_ct);
-  gbfprintf(fout, "Col=%d\n", color);
+  gbfprintf(fout, "Col=%d\n", point_color);
   if (art >= 0) {
     gbfprintf(fout, "Art=%d\n", art);
   }
index 7708c5f5832c4a2c1f4741dfb3c228a8217788ec..269c55e27b3ad1736210ae84146f73678dc4e49d 100644 (file)
@@ -372,46 +372,46 @@ GlobalsatSportFormat::track_read()
 
     for (int i = 0; i < number_headers; i++) {
       int pos = i * 29; //29=packed sizeof(gh_trainheader)
-      uint8_t* hdr = & (payload[pos]);
-      gh_trainheader header;
-      header.dateStart.Year = hdr[0];
-      header.dateStart.Month = hdr[1];
-      header.dateStart.Day = hdr[2];
-      header.timeStart.Hour = hdr[3];
-      header.timeStart.Minute = hdr[4];
-      header.timeStart.Second = hdr[5];
-      header.TotalPoint = be_read32(hdr+6);
-      header.TotalTime = be_read32(hdr+10);
-      header.TotalDistance = be_read32(hdr+14);
-      header.LapCnts = be_read16(hdr+18);
-      header.gh_ptrec.Index = be_read32(hdr+20);
-      header.gh_laprec.LapIndex = be_read32(hdr+24);
-      header.DataType = hdr[28];
+      uint8_t* th_hdr = & (payload[pos]);
+      gh_trainheader th_header;
+      th_header.dateStart.Year = th_hdr[0];
+      th_header.dateStart.Month = th_hdr[1];
+      th_header.dateStart.Day = th_hdr[2];
+      th_header.timeStart.Hour = th_hdr[3];
+      th_header.timeStart.Minute = th_hdr[4];
+      th_header.timeStart.Second = th_hdr[5];
+      th_header.TotalPoint = be_read32(th_hdr+6);
+      th_header.TotalTime = be_read32(th_hdr+10);
+      th_header.TotalDistance = be_read32(th_hdr+14);
+      th_header.LapCnts = be_read16(th_hdr+18);
+      th_header.gh_ptrec.Index = be_read32(th_hdr+20);
+      th_header.gh_laprec.LapIndex = be_read32(th_hdr+24);
+      th_header.DataType = th_hdr[28];
 
       if (showlist || global_opts.debug_level > 1) {
-        printf("Track[%02i]: %02d-%02d-%02d ", i, header.dateStart.Year, header.dateStart.Month, header.dateStart.Day);
-        printf("%02d:%02d:%02d ", header.timeStart.Hour, header.timeStart.Minute, header.timeStart.Second);
-        int time_s=header.TotalTime / 10;
+        printf("Track[%02i]: %02d-%02d-%02d ", i, th_header.dateStart.Year, th_header.dateStart.Month, th_header.dateStart.Day);
+        printf("%02d:%02d:%02d ", th_header.timeStart.Hour, th_header.timeStart.Minute, th_header.timeStart.Second);
+        int time_s=th_header.TotalTime / 10;
         int time_h=time_s/(60*60);
         time_s-=time_h*(60*60);
         int time_m=time_s/60;
         time_s-=time_m*60;
-        printf("Points:%6u Time:%02d:%02d:%02d Dist:%9um LapCnts:%5d ", header.TotalPoint, time_h, time_m, time_s, header.TotalDistance, header.LapCnts);
-        printf("Index/StartPt:%u ", header.gh_ptrec.Index);
-        printf("LapIndex/EndPt:%u ", header.gh_laprec.LapIndex);
-        printf("DataType:0x%x\n", header.DataType);
+        printf("Points:%6u Time:%02d:%02d:%02d Dist:%9um LapCnts:%5d ", th_header.TotalPoint, time_h, time_m, time_s, th_header.TotalDistance, th_header.LapCnts);
+        printf("Index/StartPt:%u ", th_header.gh_ptrec.Index);
+        printf("LapIndex/EndPt:%u ", th_header.gh_laprec.LapIndex);
+        printf("DataType:0x%x\n", th_header.DataType);
       }
 
       if (!showlist) {
         auto* trk = new route_head;
 
         trk->rte_name = QString::asprintf("%02d-%02d-%02d_%02d:%02d:%02d",
-                                          header.dateStart.Year,
-                                          header.dateStart.Month,
-                                          header.dateStart.Day,
-                                          header.timeStart.Hour,
-                                          header.timeStart.Minute,
-                                          header.timeStart.Second);
+                                          th_header.dateStart.Year,
+                                          th_header.dateStart.Month,
+                                          th_header.dateStart.Day,
+                                          th_header.timeStart.Hour,
+                                          th_header.timeStart.Minute,
+                                          th_header.timeStart.Second);
         trk->rte_desc = QString("GH625XT GPS tracklog data");
 
         track_add_head(trk);
@@ -420,8 +420,8 @@ GlobalsatSportFormat::track_read()
         GetTrack[0] = CommandGetTrackFileSections;
         GetTrack[1] = 0x0;
         GetTrack[2] = 0x1;
-        GetTrack[3] = (0xFF00 & header.gh_ptrec.Index) >> 8;
-        GetTrack[4] = 0xFF & header.gh_ptrec.Index;
+        GetTrack[3] = (0xFF00 & th_header.gh_ptrec.Index) >> 8;
+        GetTrack[4] = 0xFF & th_header.gh_ptrec.Index;
         globalsat_write_package(GetTrack, 5);
 
         uint8_t trackDeviceCommand;
@@ -579,33 +579,33 @@ GlobalsatSportFormat::track_read()
           track_payload = globalsat_read_package(&track_length, &trackDeviceCommand);
           if ((track_length > 0) && (track_payload != nullptr)) {
             //   printf("Got track package!!! Train data\n");
-            uint8_t* hdr = track_payload;
-            gh_trainheader header;
-            header.dateStart.Year = hdr[0];
-            header.dateStart.Month = hdr[1];
-            header.dateStart.Day = hdr[2];
-            header.timeStart.Hour = hdr[3];
-            header.timeStart.Minute = hdr[4];
-            header.timeStart.Second = hdr[5];
-            header.TotalPoint = be_read32(hdr+6);
-            header.TotalTime = be_read32(hdr+10);
-            header.TotalDistance = be_read32(hdr+14);
-            header.LapCnts = be_read16(hdr+18);
-            header.gh_ptrec.StartPt = be_read32(hdr+20);
-            header.gh_laprec.EndPt = be_read32(hdr+24);
-            header.DataType = hdr[28];
+            uint8_t* laptrain_hdr = track_payload;
+            gh_trainheader laptrain_header;
+            laptrain_header.dateStart.Year = laptrain_hdr[0];
+            laptrain_header.dateStart.Month = laptrain_hdr[1];
+            laptrain_header.dateStart.Day = laptrain_hdr[2];
+            laptrain_header.timeStart.Hour = laptrain_hdr[3];
+            laptrain_header.timeStart.Minute = laptrain_hdr[4];
+            laptrain_header.timeStart.Second = laptrain_hdr[5];
+            laptrain_header.TotalPoint = be_read32(laptrain_hdr+6);
+            laptrain_header.TotalTime = be_read32(laptrain_hdr+10);
+            laptrain_header.TotalDistance = be_read32(laptrain_hdr+14);
+            laptrain_header.LapCnts = be_read16(laptrain_hdr+18);
+            laptrain_header.gh_ptrec.StartPt = be_read32(laptrain_hdr+20);
+            laptrain_header.gh_laprec.EndPt = be_read32(laptrain_hdr+24);
+            laptrain_header.DataType = laptrain_hdr[28];
 
 
             if (global_opts.debug_level > 1) {
-              printf("Lap Trainheader: %02d-%02d-%02d ", header.dateStart.Year, header.dateStart.Month, header.dateStart.Day);
-              printf("%02d:%02d:%02d ", header.timeStart.Hour, header.timeStart.Minute, header.timeStart.Second);
-              printf("Total(points:%6u time:%6us dist:%9um) LapCnts:%5d ", header.TotalPoint, header.TotalTime / 10, header.TotalDistance, header.LapCnts);
-              printf("StartPt:%u ", header.gh_ptrec.StartPt);
-              printf("EndPt:%u ", header.gh_laprec.EndPt);
-              printf("DataType:0x%x\n", header.DataType);
+              printf("Lap Trainheader: %02d-%02d-%02d ", laptrain_header.dateStart.Year, laptrain_header.dateStart.Month, laptrain_header.dateStart.Day);
+              printf("%02d:%02d:%02d ", laptrain_header.timeStart.Hour, laptrain_header.timeStart.Minute, laptrain_header.timeStart.Second);
+              printf("Total(points:%6u time:%6us dist:%9um) LapCnts:%5d ", laptrain_header.TotalPoint, laptrain_header.TotalTime / 10, laptrain_header.TotalDistance, laptrain_header.LapCnts);
+              printf("StartPt:%u ", laptrain_header.gh_ptrec.StartPt);
+              printf("EndPt:%u ", laptrain_header.gh_laprec.EndPt);
+              printf("DataType:0x%x\n", laptrain_header.DataType);
             }
 
-            int recpoints_in_package = header.gh_laprec.EndPt - header.gh_ptrec.StartPt + 1;
+            int recpoints_in_package = laptrain_header.gh_laprec.EndPt - laptrain_header.gh_ptrec.StartPt + 1;
             //   printf("Recpoints Data:\n");
             uint8_t* recpoints_start_pos = track_payload + 29; //29=packed sizeof(gh_trainheader)
             for (int recpoint = 0; recpoint < recpoints_in_package; recpoint++) {
diff --git a/gui/gpsbabel b/gui/gpsbabel
new file mode 100755 (executable)
index 0000000..3907281
Binary files /dev/null and b/gui/gpsbabel differ
index 7f122527337cf42c3be7c4eed8f032d4bd9632f8..7a5adf5bb02f16ce4672a00c507f1dd199ba5a7d 100644 (file)
@@ -189,12 +189,12 @@ static const char* humminbird_icons[] = {
   "Snapshot"      /* 29 */
 };
 
-static gbfile* fin;
-static gbfile* fout;
+static gbfile* fin_;
+static gbfile* fout_;
 static int waypoint_num;
 static short_handle wptname_sh, rtename_sh, trkname_sh;
 static humminbird_rte_t* humrte;
-static int rte_num;
+static int rte_num_;
 static QMap<QString, Waypoint*> map;
 
 static
@@ -251,13 +251,13 @@ inverse_gudermannian_i1924(const double x)
 static void
 humminbird_rd_init(const QString& fname)
 {
-  fin = gbfopen_be(fname, "rb", MYNAME);
+  fin_ = gbfopen_be(fname, "rb", MYNAME);
 }
 
 static void
 humminbird_rd_deinit()
 {
-  gbfclose(fin);
+  gbfclose(fin_);
 }
 
 static void
@@ -587,22 +587,22 @@ humminbird_read_track_old(gbfile* fin)
 static void
 humminbird_read()
 {
-  while (! gbfeof(fin)) {
-    uint32_t signature = gbfgetuint32(fin);
+  while (! gbfeof(fin_)) {
+    uint32_t signature = gbfgetuint32(fin_);
 
     switch (signature) {
     case WPT_MAGIC:
     case WPT_MAGIC2:
-      humminbird_read_wpt(fin);
+      humminbird_read_wpt(fin_);
       break;
     case RTE_MAGIC:
-      humminbird_read_route(fin);
+      humminbird_read_route(fin_);
       break;
     case TRK_MAGIC:
-      humminbird_read_track(fin);
+      humminbird_read_track(fin_);
       return; /* Don't continue. The rest of the file is all zeores */
     case TRK_MAGIC2:
-      humminbird_read_track_old(fin);
+      humminbird_read_track_old(fin_);
       return; /* Don't continue. The rest of the file is all zeores */
     default:
       fatal(MYNAME ": Invalid record header \"0x%08X\" (no or unknown humminbird file)!\n", signature);
@@ -616,7 +616,7 @@ humminbird_read()
 static void
 humminbird_wr_init(const QString& fname)
 {
-  fout = gbfopen_be(fname, "wb", MYNAME);
+  fout_ = gbfopen_be(fname, "wb", MYNAME);
 
   wptname_sh = mkshort_new_handle();
 
@@ -647,7 +647,7 @@ humminbird_wr_init(const QString& fname)
   setshort_defname(trkname_sh, "Track");
 
   waypoint_num = 0;
-  rte_num = 0;
+  rte_num_ = 0;
 }
 
 static void
@@ -656,7 +656,7 @@ humminbird_wr_deinit()
   mkshort_del_handle(&wptname_sh);
   mkshort_del_handle(&rtename_sh);
   mkshort_del_handle(&trkname_sh);
-  gbfclose(fout);
+  gbfclose(fout_);
 }
 
 static void
@@ -711,8 +711,8 @@ humminbird_write_waypoint(const Waypoint* wpt)
   memset(&hum.name, 0, sizeof(hum.name));
   memcpy(&hum.name, CSTR(name), name.length());
 
-  gbfputuint32(WPT_MAGIC, fout);
-  gbfwrite(&hum, sizeof(hum), 1, fout);
+  gbfputuint32(WPT_MAGIC, fout_);
+  gbfwrite(&hum, sizeof(hum), 1, fout_);
 }
 
 static humminbird_trk_header_t* trk_head;
@@ -764,10 +764,10 @@ humminbird_track_tail(const route_head*)
   /* Actually write it out */
 
 
-  gbfputuint32(TRK_MAGIC, fout);
-  gbfwrite(trk_head, 1, sizeof(humminbird_trk_header_t), fout);
-  gbfwrite(trk_points, max_points, sizeof(humminbird_trk_point_t), fout);
-  gbfputuint16(0, fout); /* Odd but true. The format doesn't fit an int nr of entries. */
+  gbfputuint32(TRK_MAGIC, fout_);
+  gbfwrite(trk_head, 1, sizeof(humminbird_trk_header_t), fout_);
+  gbfwrite(trk_points, max_points, sizeof(humminbird_trk_point_t), fout_);
+  gbfputuint16(0, fout_); /* Odd but true. The format doesn't fit an int nr of entries. */
 
   xfree(trk_head);
   xfree(trk_points);
@@ -865,7 +865,7 @@ humminbird_rte_tail(const route_head* rte)
   }
 
   if (humrte->count > 0) {
-    humrte->num = rte_num++;
+    humrte->num = rte_num_++;
     humrte->time = gpsbabel_time;
     for (int i = 0; i < humrte->count; i++) {
       be_write16(&humrte->points[i], humrte->points[i]);
@@ -877,8 +877,8 @@ humminbird_rte_tail(const route_head* rte)
     QString name = mkshort(rtename_sh, rte->rte_name);
     strncpy(humrte->name, CSTR(name), sizeof(humrte->name));
 
-    gbfputuint32(RTE_MAGIC, fout);
-    gbfwrite(humrte, sizeof(*humrte), 1, fout);
+    gbfputuint32(RTE_MAGIC, fout_);
+    gbfwrite(humrte, sizeof(*humrte), 1, fout_);
   }
 
   xfree(humrte);
diff --git a/igc.cc b/igc.cc
index 53680465889901fe5406588e6569a86934bfdeea..1375f6c479e9444957dfb335f590539a12f43818 100644 (file)
--- a/igc.cc
+++ b/igc.cc
@@ -153,7 +153,7 @@ inline state_t& operator++(state_t& s) // prefix
 {
   return s = static_cast<state_t>(s + 1);
 }
-inline const state_t operator++(state_t& s, int) // postfix
+inline state_t operator++(state_t& s, int) // postfix
 {
   state_t ret(s);
   s = ++s;
index 1136d550420de79b5f9f3d43ae50f4cce5ba2ee0..e9dbfb868a1517a5945018a64774ecafe00f42a2 100644 (file)
@@ -171,7 +171,7 @@ ignr_rw_deinit()
 }
 
 static void
-ignr_write_track_hdr(const route_head* track)
+ignr_write_track_hdr(const route_head* track_hdr)
 {
   track_num++;
 
@@ -180,24 +180,24 @@ ignr_write_track_hdr(const route_head* track)
   }
 
   gbfprintf(fout, "\t<INFORMATIONS>\n");
-  gbfprintf(fout, "\t\t<NB_ETAPES>%d</NB_ETAPES>\n", track->rte_waypt_ct);
-  if (track->rte_desc != nullptr) {
-    gbfprintf(fout, "\t\t<DESCRIPTION>%s</DESCRIPTION>\n", CSTRc(track->rte_desc));
+  gbfprintf(fout, "\t\t<NB_ETAPES>%d</NB_ETAPES>\n", track_hdr->rte_waypt_ct);
+  if (!track_hdr->rte_desc.isEmpty()) {
+    gbfprintf(fout, "\t\t<DESCRIPTION>%s</DESCRIPTION>\n", CSTRc(track_hdr->rte_desc));
   }
   gbfprintf(fout, "\t</INFORMATIONS>\n");
 }
 
 static void
-ignr_write_waypt(const Waypoint* wpt)
+ignr_write_waypt(const Waypoint* waypoint)
 {
   if (track_num != track_index) {
     return;
   }
 
   gbfprintf(fout, "\t<ETAPE>\n");
-  gbfprintf(fout, "\t\t<POSITION>%3.6f,%3.6f</POSITION>\n", wpt->latitude, wpt->longitude);
-  if (wpt->altitude != unknown_alt) {
-    gbfprintf(fout, "\t\t<ALTITUDE>%3.6f</ALTITUDE>\n", wpt->altitude);
+  gbfprintf(fout, "\t\t<POSITION>%3.6f,%3.6f</POSITION>\n", waypoint->latitude, waypoint->longitude);
+  if (waypoint->altitude != unknown_alt) {
+    gbfprintf(fout, "\t\t<ALTITUDE>%3.6f</ALTITUDE>\n", waypoint->altitude);
   }
   gbfprintf(fout, "\t</ETAPE>\n");
 }
index 804d42836443404137a9c767053d10092021d013..fe4d08f2d9d6d33f60b18f2f7f31bf892b6782ef 100644 (file)
@@ -97,9 +97,9 @@ static void itracku_device_write_string(const char* s);
 static const char* itracku_device_read_string();
 
 /* global variables */
-static void* fd;  /* serial fd */
-static gbfile* fin; /* input file handle */
-static gbfile* fout; /* output file handle */
+static void* fd_;  /* serial fd */
+static gbfile* fin_; /* input file handle */
+static gbfile* fout_; /* output file handle */
 static gbfile* fbackup; /* backup file handle */
 static uint32_t backup_last_creation_time; /* time of last data record in backup file */
 static uint32_t new_waypoint_count; /* count of new waypoints */
@@ -126,7 +126,7 @@ itracku_device_write_string(const char* s)
 {
   int size = strlen(s) + 1;
   dbg(1, "write to device: %s", s);
-  gbser_write(fd, s, size);
+  gbser_write(fd_, s, size);
 }
 
 static const char*
@@ -134,7 +134,7 @@ itracku_device_read_string()
 {
   const int size = 1024;
   char* s = (char*) xmalloc(size);
-  gbser_read_line(fd, s, size, 1000, 0, 0);
+  gbser_read_line(fd_, s, size, 1000, 0, 0);
   dbg(1, "read from device: %s", s);
   return s;
 }
@@ -165,7 +165,7 @@ itracku_device_update_data_read(void* buf, int len)
     update_data_buffer_read = update_data_buffer;
   }
 
-  int rc = gbser_read_wait(fd, update_data_buffer_write, update_data_buffer_end - update_data_buffer_write, timeout);
+  int rc = gbser_read_wait(fd_, update_data_buffer_write, update_data_buffer_end - update_data_buffer_write, timeout);
   if (rc == gbser_ERROR) {
     return 0;
   }
@@ -339,7 +339,7 @@ init_device()
   dbg(1, "verifying device on port %s", port);
 
   itracku_device_write_string("WP AP-Exit");
-  gbser_flush(fd);
+  gbser_flush(fd_);
   itracku_device_write_string("W'P Camera Detect");
   const char* greeting = itracku_device_read_string();
 
@@ -390,13 +390,13 @@ itracku_rd_ser_init(const QString& fname)
 #if LATER
   if (0 == strcmp(qPrintable(fname), port_auto_detect_filename)) {
     dbg(1, "auto detecting port for iTrackU device");
-    for (int i=1; !fd && i<port_auto_detect_max_port; ++i) {
+    for (int i=1; !fd_ && i<port_auto_detect_max_port; ++i) {
       xasprintf(&port, "com%d", i);
       if (!gbser_is_serial(port)) {
         break;
       }
       dbg(1, "trying port %s", port);
-      if ((fd = gbser_init(port)) == NULL) {
+      if ((fd_ = gbser_init(port)) == NULL) {
         dbg(1, "port %s not available.", port);
         continue;
       }
@@ -405,17 +405,17 @@ itracku_rd_ser_init(const QString& fname)
         break;
       }
 
-      gbser_deinit(fd);
-      fd = NULL;
+      gbser_deinit(fd_);
+      fd_ = NULL;
       xfree(port);
     }
-    for (int i=0; !fd && i<port_auto_detect_max_port; ++i) {
+    for (int i=0; !fd_ && i<port_auto_detect_max_port; ++i) {
       xasprintf(&port, "/dev/ttyUSB%d", i);
       if (!gbser_is_serial(port)) {
         break;
       }
       dbg(1, "trying port %s", port);
-      if ((fd = gbser_init(port)) == NULL) {
+      if ((fd_ = gbser_init(port)) == NULL) {
         dbg(1, "port %s not available.", port);
         continue;
       }
@@ -424,11 +424,11 @@ itracku_rd_ser_init(const QString& fname)
         break;
       }
 
-      gbser_deinit(fd);
-      fd = NULL;
+      gbser_deinit(fd_);
+      fd_ = NULL;
       xfree(port);
     }
-    if (fd == NULL) {
+    if (fd_ == NULL) {
       fatal(MYNAME ": could not find device");
     }
   } else
@@ -439,7 +439,7 @@ itracku_rd_ser_init(const QString& fname)
       port = xstrdup(qPrintable(fname));
 
       dbg(1, "opening port %s", qPrintable(fname));
-      if ((fd = gbser_init(port)) == nullptr) {
+      if ((fd_ = gbser_init(port)) == nullptr) {
         fatal(MYNAME ": can't initialise port \"%s\"", port);
       }
 
@@ -457,7 +457,7 @@ itracku_rd_ser_init(const QString& fname)
 static void
 itracku_rd_init(const QString& fname)
 {
-  fin = gbfopen(fname, "r", MYNAME);
+  fin_ = gbfopen(fname, "r", MYNAME);
   itracku_rd_init_common(fname);
 }
 
@@ -465,16 +465,16 @@ static void
 itracku_rd_deinit()
 {
   dbg(1, "%d new waypoints", new_waypoint_count);
-  if (fd) {
+  if (fd_) {
     dbg(3, "closing port %s", port);
-    gbser_deinit(fd);
-    fd = nullptr;
+    gbser_deinit(fd_);
+    fd_ = nullptr;
     xfree(port);
     port = nullptr;
   }
-  if (fin) {
-    gbfclose(fin);
-    fin = nullptr;
+  if (fin_) {
+    gbfclose(fin_);
+    fin_ = nullptr;
   }
   if (fbackup) {
     gbfclose(fbackup);
@@ -581,10 +581,10 @@ itracku_file_write_waypt(gbfile* fout, const Waypoint* wpt)
 static void
 itracku_waypt_input(void (*waypt_add)(Waypoint*))
 {
-  if (fd) {
-    itracku_device_dump_waypts(fd, waypt_add);
+  if (fd_) {
+    itracku_device_dump_waypts(fd_, waypt_add);
   } else {
-    itracku_file_read_waypts(fin, waypt_add);
+    itracku_file_read_waypts(fin_, waypt_add);
   }
 }
 
@@ -632,19 +632,19 @@ itracku_read()
 static void
 itracku_wr_init(const QString& fname)
 {
-  fout = gbfopen(fname, "w", MYNAME);
+  fout_ = gbfopen(fname, "w", MYNAME);
 }
 
 static void
 itracku_wr_deinit()
 {
-  gbfclose(fout);
+  gbfclose(fout_);
 }
 
 static void
 itracku_output_waypoint(const Waypoint* wp)
 {
-  itracku_file_write_waypt(fout, wp);
+  itracku_file_write_waypt(fout_, wp);
 }
 
 static void
@@ -743,7 +743,7 @@ itracku_rt_position(posn_status*)
 {
   char line[1024];
   while (true) {
-    gbser_read_line(fd, line, sizeof(line), 5000, 13, 10);
+    gbser_read_line(fd_, line, sizeof(line), 5000, 13, 10);
     dbg(1, line);
     Waypoint* wpt = gprmc_parse(line);
     if (wpt) {
index 3f97922e59a1e3fa867798a67d5a947668f44345..dcf7c1a46740960ae97a4a121118183c8f364ef9 100644 (file)
@@ -148,8 +148,8 @@ int32 GPS_Serial_Packet_Read(gpsdevh* fd, GPS_PPacket* packet)
           m1 = Get_Pkt_Type((*packet).type, (*packet).data[0], &m2);
           if (gps_show_bytes) {
             GPS_Diag(" ");
-            for (unsigned i = 0; i < packet->n; i++) {
-              char c = (*packet).data[i];
+            for (unsigned j = 0; j < packet->n; j++) {
+              char c = (*packet).data[j];
               GPS_Diag("%c", isascii(c) && isalnum(c) ? c : '.');
             }
             GPS_Diag(" ");
index 846380c30fc622700a8f4cfd28aae5eb5999ba91..ff602d0ae4fe7f02c529fc46bec6d476694f7fdb 100644 (file)
@@ -1002,7 +1002,7 @@ LowranceusrFormat::lowranceusr_parse_trail(int* trail_num)
 
     while (num_trail_points && !gbfeof(file_in)) {
       /* num section points */
-      short int num_section_points = gbfgetint16(file_in);
+      num_section_points = gbfgetint16(file_in);
 
       if (global_opts.debug_level > 1) {
         printf(MYNAME " parse_trails: Num Section Points = %d\n", num_section_points);
@@ -1013,9 +1013,10 @@ LowranceusrFormat::lowranceusr_parse_trail(int* trail_num)
         wpt_tmp->latitude = lat_mm_to_deg(gbfgetint32(file_in));
         wpt_tmp->longitude = lon_mm_to_deg(gbfgetint32(file_in));
 
-        /* continuous */
-        char continuous = gbfgetc(file_in);
-        if (!continuous && opt_seg_break && j) {
+        // It's not clear if this should be the continuous global or
+        // a local continuous_flag.
+        char continuous_flag = gbfgetc(file_in);
+        if (!continuous_flag && opt_seg_break && j) {
           /* option to break trails into segments was specified */
           auto* trk_tmp = new route_head;
           trk_tmp->rte_num = ++(*trail_num);
diff --git a/main.cc b/main.cc
index bc7f56097ee34e2f3445f105e2be45fcd2241b13..2e289390cd4c678567f99886fb14209cbbe8f18d 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -262,7 +262,7 @@ run(const char* prog_name)
    */
   argn = 1;
   while (argn < qargs.size()) {
-    QString optarg;
+    QString argument;
 
 //  we must check the length for afl input fuzzing to work.
 //    if (qargs.at(argn).at(0).toLatin1() != '-') {
@@ -298,25 +298,25 @@ run(const char* prog_name)
 
     switch (c) {
     case 'i':
-      optarg = FETCH_OPTARG;
-      ivecs = Vecs::Instance().find_vec(optarg);
+      argument = FETCH_OPTARG;
+      ivecs = Vecs::Instance().find_vec(argument);
       if (ivecs == nullptr) {
-        fatal("Input type '%s' not recognized\n", qPrintable(optarg));
+        fatal("Input type '%s' not recognized\n", qPrintable(argument));
       }
       break;
     case 'o':
       if (ivecs == nullptr) {
         warning("-o appeared before -i.   This is probably not what you want to do.\n");
       }
-      optarg = FETCH_OPTARG;
-      ovecs = Vecs::Instance().find_vec(optarg);
+      argument = FETCH_OPTARG;
+      ovecs = Vecs::Instance().find_vec(argument);
       if (ovecs == nullptr) {
-        fatal("Output type '%s' not recognized\n", qPrintable(optarg));
+        fatal("Output type '%s' not recognized\n", qPrintable(argument));
       }
       break;
     case 'f':
-      optarg = FETCH_OPTARG;
-      fname = optarg;
+      argument = FETCH_OPTARG;
+      fname = argument;
       if (fname.isEmpty()) {
         fatal("No file or device name specified.\n");
       }
@@ -344,8 +344,8 @@ run(const char* prog_name)
       did_something = true;
       break;
     case 'F':
-      optarg = FETCH_OPTARG;
-      ofname = optarg;
+      argument = FETCH_OPTARG;
+      ofname = argument;
       if (ofname.isEmpty()) {
         fatal("No output file or device name specified.\n");
       }
@@ -398,8 +398,8 @@ run(const char* prog_name)
       }
       break;
     case 'x':
-      optarg = FETCH_OPTARG;
-      filter = FilterVecs::Instance().find_filter_vec(optarg);
+      argument = FETCH_OPTARG;
+      filter = FilterVecs::Instance().find_filter_vec(argument);
 
       if (filter) {
         filter->init();
@@ -407,14 +407,14 @@ run(const char* prog_name)
         filter->deinit();
         FilterVecs::free_filter_vec(filter);
       }  else {
-        fatal("Unknown filter '%s'\n",qPrintable(optarg));
+        fatal("Unknown filter '%s'\n",qPrintable(argument));
       }
       break;
     case 'D':
-      optarg = FETCH_OPTARG;
+      argument = FETCH_OPTARG;
       {
         bool ok;
-        global_opts.debug_level = optarg.toInt(&ok);
+        global_opts.debug_level = argument.toInt(&ok);
         if (!ok) {
           fatal("the -D option requires an integer value to specify the debug level, i.e. -D level\n");
         }
@@ -476,18 +476,18 @@ run(const char* prog_name)
       usage(prog_name,0);
       return 0;
     case 'p':
-      optarg = FETCH_OPTARG;
+      argument = FETCH_OPTARG;
       inifile_done(global_opts.inifile);
-      if (optarg.isEmpty()) {  /* from GUI to preserve inconsistent options */
+      if (argument.isEmpty()) {        /* from GUI to preserve inconsistent options */
         global_opts.inifile = nullptr;
       } else {
-        global_opts.inifile = inifile_init(optarg, MYNAME);
+        global_opts.inifile = inifile_init(argument, MYNAME);
       }
       break;
     case 'b':
-      optarg = FETCH_OPTARG;
+      argument = FETCH_OPTARG;
       qargs_stack.push(QargStackElement(argn, qargs));
-      qargs = load_args(optarg, qargs.at(0));
+      qargs = load_args(argument, qargs.at(0));
       if (qargs.empty()) {
         QargStackElement ele = qargs_stack.pop();
         argn = ele.argn;
diff --git a/mmo.cc b/mmo.cc
index bdb477ffd57595609fc30646d2b252ca992b1d5f..4a8157ca3e5129f11540488db8615727dd9300b9 100644 (file)
--- a/mmo.cc
+++ b/mmo.cc
@@ -640,7 +640,7 @@ mmo_read_CObjTrack(mmo_data_t* data)
     DBG((sobj, "unknown value = 0x%04X (since 0x18)\n", u16));
     u16 = gbfgetuint16(fin);
     DBG((sobj, "unknown value = 0x%04X (since 0x18)\n", u16));
-    (void) u16;
+    Q_UNUSED(u16);
   }
 
   int tp = gbfgetint16(fin);
@@ -661,12 +661,12 @@ mmo_read_CObjTrack(mmo_data_t* data)
     if (unk != 0) {
       uint16_t ux = gbfgetuint16(fin);
       DBG((sobj, "unknown value = 0x%04X (%d)\n", ux, ux));
-      (void) ux;
+      Q_UNUSED(ux);
       if (unk > 1) {
-        uint16_t ux;
-        ux = gbfgetuint16(fin);
-        DBG((sobj, "unknown value = 0x%04X (%d)\n", ux, ux));
-        (void) ux;
+        uint16_t unknown;
+        unknown = gbfgetuint16(fin);
+        DBG((sobj, "unknown value = 0x%04X (%d)\n", unknown, unknown));
+        Q_UNUSED(unknown);
       }
     }
     track_add_wpt(trk, wpt);
@@ -690,7 +690,7 @@ mmo_read_CObjTrack(mmo_data_t* data)
     trk->line_color.bbggrr = gbfgetuint32(fin);        /* rgb color */
     trk->line_color.opacity = 255;
     DBG((sobj, "color = 0x%06X\n", trk->line_color.bbggrr));
-    (void) u32;
+    Q_UNUSED(u32);
   }
 
   if (mmo_version >= 0x12) {
@@ -717,7 +717,7 @@ mmo_read_CObjTrack(mmo_data_t* data)
       DBG((sobj, "unknown value = 0x%04X (since 0x16)\n", u16));
       u16 = gbfgetuint16(fin);
       DBG((sobj, "unknown value = 0x%04X (since 0x16)\n", u16));
-      (void) u16;
+      Q_UNUSED(u16);
     }
   }
 
@@ -743,8 +743,8 @@ mmo_read_CObjText(mmo_data_t*)
   double lat = gbfgetdbl(fin);
   double lon = gbfgetdbl(fin);
   DBG((sobj, "coordinates = %f / %f\n", lat, lon));
-  (void) lat;
-  (void) lon;
+  Q_UNUSED(lat);
+  Q_UNUSED(lon);
 
   // Don't construct a QString we aren't going to use.
   // avoid clazy-unused-non-trivial-variable
@@ -787,8 +787,8 @@ mmo_read_CObjCurrentPosition(mmo_data_t*)
   double lat = gbfgetdbl(fin);
   double lon = gbfgetdbl(fin);
   DBG((sobj, "coordinates = %f / %f\n", lat, lon));
-  (void) lat;
-  (void) lon;
+  Q_UNUSED(lat);
+  Q_UNUSED(lon);
 
   mmo_fillbuf(buf, 24, 1);
   if (mmo_version >= 0x18) {
diff --git a/nmea.cc b/nmea.cc
index 3366bdcc466aec2df68484e2d97ab85781fda1d1..9de6c7942ae4385c10e04292f1fc8f2dd9b2e91f 100644 (file)
--- a/nmea.cc
+++ b/nmea.cc
@@ -795,11 +795,11 @@ NmeaFormat::pcmpt_parse(char* ibuf)
      * we can rip through the queue forward now to get our
      * handy-dandy reversing effect.
      */
-    auto* trk_head = new route_head;
-    track_add_head(trk_head);
+    auto* trk_head_2 = new route_head;
+    track_add_head(trk_head_2);
     while (!pcmpt_head.isEmpty()) {
       Waypoint* wpt = pcmpt_head.takeFirst();
-      nmea_add_wpt(wpt, trk_head);
+      nmea_add_wpt(wpt, trk_head_2);
     }
   }
 }
diff --git a/osm.cc b/osm.cc
index b7db37769fd9d5d4c212e67ebd5fefafdd73a622..e7b86204d501b4cd79d81cbca2de12451ca3b6e9 100644 (file)
--- a/osm.cc
+++ b/osm.cc
@@ -721,10 +721,10 @@ osm_write_tag(const QString& key, const QString& value)
 }
 
 static void
-osm_disp_feature(const Waypoint* wpt)
+osm_disp_feature(const Waypoint* waypoint)
 {
-  if (icons.contains(wpt->icon_descr)) {
-    const osm_icon_mapping_t* map = icons.value(wpt->icon_descr);
+  if (icons.contains(waypoint->icon_descr)) {
+    const osm_icon_mapping_t* map = icons.value(waypoint->icon_descr);
     osm_write_tag(osm_features[map->key], map->value);
   }
 }
@@ -759,61 +759,61 @@ osm_write_opt_tag(const char* atag)
 }
 
 static void
-osm_release_ids(const Waypoint* wpt)
+osm_release_ids(const Waypoint* waypoint)
 {
-  if (wpt && wpt->extra_data) {
-    auto* tmp = const_cast<Waypoint*>(wpt);
+  if (waypoint && waypoint->extra_data) {
+    auto* tmp = const_cast<Waypoint*>(waypoint);
     xfree(tmp->extra_data);
     tmp->extra_data = nullptr;
   }
 }
 
 static QString
-osm_name_from_wpt(const Waypoint* wpt)
+osm_name_from_wpt(const Waypoint* waypoint)
 {
   QString name = QString("%1\01%2\01%3")
-                 .arg(wpt->shortname)
-                 .arg(wpt->latitude)
-                 .arg(wpt->longitude);
+                 .arg(waypoint->shortname)
+                 .arg(waypoint->latitude)
+                 .arg(waypoint->longitude);
   return name;
 }
 
 static void
-osm_waypt_disp(const Waypoint* wpt)
+osm_waypt_disp(const Waypoint* waypoint)
 {
-  QString name = osm_name_from_wpt(wpt);
+  QString name = osm_name_from_wpt(waypoint);
 
   if (waypoints.contains(name)) {
     return;
   }
 
-  waypoints.insert(name, wpt);
+  waypoints.insert(name, waypoint);
 
   int* id = (int*) xmalloc(sizeof(*id));
   *id = --node_id;
-  (const_cast<Waypoint*>(wpt))->extra_data = id;
+  (const_cast<Waypoint*>(waypoint))->extra_data = id;
 
-  gbfprintf(fout, "  <node id='%d' visible='true' lat='%0.7f' lon='%0.7f'", *id, wpt->latitude, wpt->longitude);
-  if (wpt->creation_time.isValid()) {
-    QString time_string = wpt->CreationTimeXML();
+  gbfprintf(fout, "  <node id='%d' visible='true' lat='%0.7f' lon='%0.7f'", *id, waypoint->latitude, waypoint->longitude);
+  if (waypoint->creation_time.isValid()) {
+    QString time_string = waypoint->CreationTimeXML();
     gbfprintf(fout, " timestamp='%s'", qPrintable(time_string));
   }
   gbfprintf(fout, ">\n");
 
-  if (wpt->hdop) {
-    gbfprintf(fout, "    <tag k='gps:hdop' v='%f' />\n", wpt->hdop);
+  if (waypoint->hdop) {
+    gbfprintf(fout, "    <tag k='gps:hdop' v='%f' />\n", waypoint->hdop);
   }
-  if (wpt->vdop) {
-    gbfprintf(fout, "    <tag k='gps:vdop' v='%f' />\n", wpt->vdop);
+  if (waypoint->vdop) {
+    gbfprintf(fout, "    <tag k='gps:vdop' v='%f' />\n", waypoint->vdop);
   }
-  if (wpt->pdop) {
-    gbfprintf(fout, "    <tag k='gps:pdop' v='%f' />\n", wpt->pdop);
+  if (waypoint->pdop) {
+    gbfprintf(fout, "    <tag k='gps:pdop' v='%f' />\n", waypoint->pdop);
   }
-  if (wpt->sat > 0) {
-    gbfprintf(fout, "    <tag k='gps:sat' v='%d' />\n", wpt->sat);
+  if (waypoint->sat > 0) {
+    gbfprintf(fout, "    <tag k='gps:sat' v='%d' />\n", waypoint->sat);
   }
 
-  switch (wpt->fix) {
+  switch (waypoint->fix) {
   case fix_2d:
     gbfprintf(fout, "    <tag k='gps:fix' v='2d' />\n");
     break;
@@ -843,10 +843,10 @@ osm_waypt_disp(const Waypoint* wpt)
     gbfprintf(fout, "'/>\n");
   }
 
-  osm_write_tag("name", wpt->shortname);
-  osm_write_tag("note", (wpt->notes.isEmpty()) ? wpt->description : wpt->notes);
-  if (!wpt->icon_descr.isNull()) {
-    osm_disp_feature(wpt);
+  osm_write_tag("name", waypoint->shortname);
+  osm_write_tag("note", (waypoint->notes.isEmpty()) ? waypoint->description : waypoint->notes);
+  if (!waypoint->icon_descr.isNull()) {
+    osm_disp_feature(waypoint);
   }
 
   osm_write_opt_tag(opt_tagnd);
@@ -855,9 +855,9 @@ osm_waypt_disp(const Waypoint* wpt)
 }
 
 static void
-osm_rte_disp_head(const route_head* rte)
+osm_rte_disp_head(const route_head* route)
 {
-  skip_rte = (rte->rte_waypt_ct <= 0);
+  skip_rte = (route->rte_waypt_ct <= 0);
 
   if (skip_rte) {
     return;
@@ -876,14 +876,14 @@ osm_rtept_disp(const Waypoint* wpt_ref)
   }
 
   if (waypoints.contains(name)) {
-    const Waypoint* wpt = waypoints.value(name);
-    int* id = (int*) wpt->extra_data;
+    const Waypoint* waypoint = waypoints.value(name);
+    int* id = (int*) waypoint->extra_data;
     gbfprintf(fout, "    <nd ref='%d'/>\n", *id);
   }
 }
 
 static void
-osm_rte_disp_trail(const route_head* rte)
+osm_rte_disp_trail(const route_head* route)
 {
   if (skip_rte) {
     return;
@@ -898,8 +898,8 @@ osm_rte_disp_trail(const route_head* rte)
     gbfprintf(fout, "'/>\n");
   }
 
-  osm_write_tag("name", rte->rte_name);
-  osm_write_tag("note", rte->rte_desc);
+  osm_write_tag("name", route->rte_name);
+  osm_write_tag("note", route->rte_desc);
 
   if (opt_tag && (case_ignore_strncmp(opt_tag, "tagnd", 5) != 0)) {
     osm_write_opt_tag(opt_tag);
index 12941cf1f3b19709b65c2868b93ad9c9b3751214..680ebc209f5258a546ea5c266d03457655bf0d5f 100644 (file)
@@ -128,8 +128,10 @@ pocketfms_waypt_disp(const Waypoint* wpt)
   const time_t tt = wpt->GetCreationTime().toTime_t();
   struct tm* tm = localtime(&tt);
   if (wpt->creation_time.isValid()) {
-    const time_t tt = wpt->GetCreationTime().toTime_t();
-    tm = gmtime(&tt);
+    // It seems odd to reread waypoint time here, but this whole format
+    // is likely short-lived.
+    const time_t tt2 = wpt->GetCreationTime().toTime_t();
+    tm = gmtime(&tt2);
   }
 
   strcpy(bc.id, header_id);
index c4deff26a12551b041199d5f62ec0614aa4280ac..827f2c38e1cefb72440d1ccd79b436fc97b5bd21 100644 (file)
@@ -325,8 +325,9 @@ qsort_cb(const void* a, const void* b)
   return wa->shortname.compare(wb->shortname);
 }
 
+// TODO: this first arg is both a global and a param. That's weird.
 static void
-write_waypoint(gbfile* fout, const Waypoint* wpt, const int waypt_no, const char* location)
+write_waypoint(gbfile* fileout, const Waypoint* wpt, const int waypt_no, const char* location)
 {
   QString notes = wpt->notes;
   if (notes == nullptr) {
@@ -339,14 +340,14 @@ write_waypoint(gbfile* fout, const Waypoint* wpt, const int waypt_no, const char
   double time = wpt->creation_time.isValid() ? TIMET_TO_EXCEL(wpt->GetCreationTime().toTime_t()) : TIMET_TO_EXCEL(gpsbabel_time);
   char* name = (char*)wpt->extra_data;
 
-  gbfprintf(fout, "[Wp%d]" LINE_FEED
+  gbfprintf(fileout, "[Wp%d]" LINE_FEED
             "Loc=%s" LINE_FEED
             "Name=%s" LINE_FEED
             "Lat=%.15f" LINE_FEED
             "Long=%.15f" LINE_FEED,
             waypt_no, location, name, wpt->latitude, wpt->longitude
            );
-  gbfprintf(fout, "Rng=%.15f" LINE_FEED
+  gbfprintf(fileout, "Rng=%.15f" LINE_FEED
             "Bear=%.15f" LINE_FEED
             "Bmp=%d" LINE_FEED
             "Fixed=1" LINE_FEED
@@ -356,7 +357,7 @@ write_waypoint(gbfile* fout, const Waypoint* wpt, const int waypt_no, const char
             find_symbol_num(wpt->icon_descr),
             CSTR(notes)
            );
-  gbfprintf(fout, "Rel=" LINE_FEED
+  gbfprintf(fileout, "Rel=" LINE_FEED
             "RelSet=0" LINE_FEED
             "RcCount=0" LINE_FEED
             "RcRadius=%.15f" LINE_FEED
index 2cde1145c37f3e3e57afe7c818a84f6934d1856d..36470f4eeac44cfa42b5a7f370c70485bde70fb7 100644 (file)
--- a/route.cc
+++ b/route.cc
@@ -460,7 +460,7 @@ RouteList::copy(RouteList** dst) const
   }
 
   const char RPT[] = "RPT";
-  foreach (const route_head* rte_old, *this) {
+  for (const auto& rte_old : *this) {
     auto* rte_new = new route_head;
     // waypoint_list created below with add_wpt.
     rte_new->rte_name = rte_old->rte_name;
@@ -473,7 +473,8 @@ RouteList::copy(RouteList** dst) const
     rte_new->line_width = rte_old->line_width;
     rte_new->session = rte_old->session;
     (*dst)->add_head(rte_new);
-    foreach (const Waypoint* old_wpt, rte_old->waypoint_list) {
+    const auto& old_list = rte_old->waypoint_list;
+    for (const auto& old_wpt : old_list) {
       (*dst)->add_wpt(rte_new, new Waypoint(*old_wpt), false, RPT, 3);
     }
   }
index 9c349f884435925f6fe1f1ba28b3c18debca6d8c..51bef2b5b8401e8cd3b045d486fe5640c751d8b6 100644 (file)
@@ -66,7 +66,7 @@ skyforce_parse_coords(const char* str)
 
 
 static Waypoint*
-skyforce_parse_wpt(const char* str, int* rte_num)
+skyforce_parse_wpt(const char* str, int* rte_num_out)
 {
   Waypoint* wpt = skyforce_parse_coords(str);
   if (wpt == nullptr) {
@@ -78,8 +78,8 @@ skyforce_parse_wpt(const char* str, int* rte_num)
   // Grab "BEARHILL" and whack trailing space.
   wpt->shortname = QString(str).mid(10,9).trimmed();
 
-  if (rte_num) {
-    *rte_num = atoi(str + 2);
+  if (rte_num_out) {
+    *rte_num_out = atoi(str + 2);
   }
 
   return wpt;
index f74cbdf738f421e4c37ab9872a6436653f197932..b7e130f724bf9a0f03adf3d0d41afda57e9abcef 100644 (file)
--- a/stmwpp.cc
+++ b/stmwpp.cc
@@ -235,7 +235,7 @@ stmwpp_write_double(const double val)
 }
 
 static void
-stmwpp_waypt_cb(const Waypoint* wpt)
+stmwpp_waypt_cb(const Waypoint* waypoint)
 {
   if (track_index != track_num) {
     return;
@@ -247,9 +247,9 @@ stmwpp_waypt_cb(const Waypoint* wpt)
   case STM_WAYPT:
   case STM_RTEPT:
     if (global_opts.synthesize_shortnames) {
-      sn = mkshort_from_wpt(short_h, wpt);
+      sn = mkshort_from_wpt(short_h, waypoint);
     } else {
-      sn = mkshort(short_h, wpt->shortname);
+      sn = mkshort(short_h, waypoint->shortname);
     }
     gbfprintf(fout, "WP,D,%s,", CSTRc(sn));
     break;
@@ -258,9 +258,9 @@ stmwpp_waypt_cb(const Waypoint* wpt)
     gbfprintf(fout, "TP,D,");
     break;
   }
-  stmwpp_write_double(wpt->latitude);
-  stmwpp_write_double(wpt->longitude);
-  QString datetime = wpt->GetCreationTime().toUTC().toString("MM/dd/yyyy,HH:mm:ss");
+  stmwpp_write_double(waypoint->latitude);
+  stmwpp_write_double(waypoint->longitude);
+  QString datetime = waypoint->GetCreationTime().toUTC().toString("MM/dd/yyyy,HH:mm:ss");
   gbfputs(datetime, fout);
   switch (what) {
   case STM_WAYPT:
@@ -268,7 +268,7 @@ stmwpp_waypt_cb(const Waypoint* wpt)
     gbfprintf(fout, ".%02d", 0);
     break;
   case STM_TRKPT:
-    gbfprintf(fout, ".%03d", wpt->GetCreationTime().time().msec());
+    gbfprintf(fout, ".%03d", waypoint->GetCreationTime().time().msec());
     break;
   }
   gbfprintf(fout, ",\r\n");
index ff741a866e9fa26f78e239da98defcf4f8049126..ab41748e9bec33f26b0e86c274a6dfa6c31cef75 100644 (file)
--- a/unicsv.cc
+++ b/unicsv.cc
@@ -920,20 +920,20 @@ UnicsvFormat::unicsv_parse_one_line(const QString& ibuf)
         gc_data->is_available = unicsv_parse_status(value);
         break;
       case fld_gc_exported: {
-        time_t time, date;
-        int usec;
-        time = unicsv_parse_time(value, &usec, &date);
-        if (date || time) {
-          gc_data->exported = unicsv_adjust_time(time, &date);
+        time_t etime, edate;
+        int eusec;
+        etime = unicsv_parse_time(value, &eusec, &edate);
+        if (edate || etime) {
+          gc_data->exported = unicsv_adjust_time(etime, &edate);
         }
       }
       break;
       case fld_gc_last_found: {
-        time_t time, date;
-        int usec;
-        time = unicsv_parse_time(value, &usec, &date);
-        if (date || time) {
-          gc_data->last_found = unicsv_adjust_time(time, &date);
+        time_t ftime, fdate;
+        int fusec;
+        ftime = unicsv_parse_time(value, &fusec, &fdate);
+        if (fdate || ftime) {
+          gc_data->last_found = unicsv_adjust_time(ftime, &fdate);
         }
       }
       break;
diff --git a/xmldoc/formats/options/energympro-timezone.xml b/xmldoc/formats/options/energympro-timezone.xml
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/xmldoc/formats/options/globalsat-timezone.xml b/xmldoc/formats/options/globalsat-timezone.xml
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
diff --git a/xol.cc b/xol.cc
index 76cb7d1b48e58c723551dbe5197b870dfd64ad76..e03a43e65c4d4301b7431e6970f0e616d73df2e0 100644 (file)
--- a/xol.cc
+++ b/xol.cc
@@ -30,8 +30,8 @@
 #include <QtCore/QXmlStreamAttributes>
 #include <QtCore/QXmlStreamWriter>
 
-static Waypoint* wpt;
-static route_head* trk;
+static Waypoint* wpt_;
+static route_head* trk_;
 static bounds all_bounds;
 static short_handle short_h;
 
@@ -66,54 +66,54 @@ static void xol_overlay(xg_string, const QXmlStreamAttributes* attrv) {
 static void xol_shape(xg_string, const QXmlStreamAttributes* attrv) {
   if (attrv->hasAttribute("type")) {
     if (attrv->value("type") == "waypoint") {
-      wpt = new Waypoint;
+      wpt_ = new Waypoint;
     } else if (attrv->value("type") == "polyline") {
-      trk = new route_head;
-      track_add_head(trk);
+      trk_ = new route_head;
+      track_add_head(trk_);
     }
   }
 
   if (attrv->hasAttribute("name")) {
-    if (wpt) {
-      wpt->shortname = attrv->value("name").toString();
-    } else if (trk) {
-      trk->rte_name = attrv->value("name").toString();
+    if (wpt_) {
+      wpt_->shortname = attrv->value("name").toString();
+    } else if (trk_) {
+      trk_->rte_name = attrv->value("name").toString();
     }
   }
 
-  if (wpt) {
+  if (wpt_) {
     if (attrv->hasAttribute("comment")) {
-      wpt->notes = attrv->value("comment").toString();
+      wpt_->notes = attrv->value("comment").toString();
     }
 
     if (attrv->hasAttribute("alt")) {
-      wpt->altitude = attrv->value("alt").toString().toDouble();
+      wpt_->altitude = attrv->value("alt").toString().toDouble();
     }
 
     if (attrv->hasAttribute("timestamp")) {
-      wpt->creation_time = xml_parse_time(
+      wpt_->creation_time = xml_parse_time(
           attrv->value("timestamp").toString().toUtf8().constData());
     }
 
     if (attrv->hasAttribute("icon")) {
-      wpt->icon_descr = attrv->value("icon").toString();
+      wpt_->icon_descr = attrv->value("icon").toString();
     }
   }
 }
 
 static void xol_shape_end(xg_string, const QXmlStreamAttributes*) {
-  if (wpt) {
-    if (trk) {
-      track_add_wpt(trk, wpt);
+  if (wpt_) {
+    if (trk_) {
+      track_add_wpt(trk_, wpt_);
     } else {
-      waypt_add(wpt);
+      waypt_add(wpt_);
     }
-    wpt = nullptr;
-  } else if (trk) {
-    if (trk->rte_waypt_ct == 0) {
-      track_del_head(trk);
+    wpt_ = nullptr;
+  } else if (trk_) {
+    if (trk_->rte_waypt_ct == 0) {
+      track_del_head(trk_);
     }
-    trk = nullptr;
+    trk_ = nullptr;
   }
 }
 
@@ -128,12 +128,12 @@ static void xol_waypt(xg_string, const QXmlStreamAttributes* attrv) {
     x = attrv->value("x").toString().toInt();
   }
 
-  GPS_Math_Swiss_EN_To_WGS84(x, y, &wpt->latitude, &wpt->longitude);
+  GPS_Math_Swiss_EN_To_WGS84(x, y, &wpt_->latitude, &wpt_->longitude);
 }
 
 static void xol_rd_init(const QString& fname) {
-  trk = nullptr;
-  wpt = nullptr;
+  trk_ = nullptr;
+  wpt_ = nullptr;
 
   xml_init(fname, xol_map, nullptr);
 }
@@ -144,15 +144,15 @@ static void xol_rd_deinit() { xml_deinit(); }
 
 /* writer */
 
-static void xol_fatal_outside(const Waypoint* wpt) {
+static void xol_fatal_outside(const Waypoint* waypoint) {
   fatal(MYNAME ": %s (%s) is outside of convertible area \"%s\"!\n",
-        wpt->shortname.isEmpty() ? "Waypoint" : qPrintable(wpt->shortname),
-        pretty_deg_format(wpt->latitude, wpt->longitude, 'd', nullptr, 0),
+        waypoint->shortname.isEmpty() ? "Waypoint" : qPrintable(waypoint->shortname),
+        pretty_deg_format(waypoint->latitude, waypoint->longitude, 'd', nullptr, 0),
         gt_get_mps_grid_longname(grid_swiss, MYNAME));
 }
 
-static void xol_waypt_bound_calc(const Waypoint* wpt) {
-  waypt_add_to_bounds(&all_bounds, wpt);
+static void xol_waypt_bound_calc(const Waypoint* waypoint) {
+  waypt_add_to_bounds(&all_bounds, waypoint);
 }
 
 static void xol_wr_init(const QString& fname) {